from flask import Flask,request, render_template
import pandas as pd
from sklearn import datasets
from scipy import stats
import numpy as np



#app = Flask(__name__)
app = Flask(__name__,
            static_folder='./static',
            static_url_path="")


@app.route('/pdf')
def test_pdf():   
    diab = datasets.load_iris()
    #diab = datasets.load_diabetes()
    x1 = [item[0] for item in diab.data]
    print(x1)  
    gkde = stats.gaussian_kde(dataset=x1)
    x = np.linspace(start=4, stop=8, num=200)

    y = gkde.evaluate(x)
    print(x)
    print(y)
    
    return render_template('pdf.html', x=list(x), y=list(y), curTitle="PDF")

@app.route('/cdf')
def test_cdf():   
    diab = datasets.load_iris()

    x1 = [item[0] for item in diab.data]  
    res = stats.ecdf(x1)
    x= res.cdf.quantiles
    y = res.cdf.probabilities
 
    return render_template('pdf.html', x=list(x), y=list(y), curTitle="CDF")

@app.route('/box')
def test_box():   
    diab = datasets.load_iris()
    x1 = [item[0] for item in diab.data]  

    return render_template('boxplot.html', x=x1)





if __name__ == '__main__':
    print('test')
    app.run(debug=True,host='0.0.0.0',port=25001)